<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="base.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=GBK" />
	<title>新建项目</title>
	<link rel="stylesheet" type="text/css" href="${basePath}/style/reset.css" media="all" />
	<link rel="stylesheet" type="text/css" href="${basePath}/style/layout.css" media="all" />
	<link rel="stylesheet" type="text/css" href="${basePath}/style/invalid.css" media="all" />
	<link rel="stylesheet" type="text/css" href="${basePath}/style/style.css" media="all" />
	<script type="text/javascript" src="${basePath}/script/jquery-1.4.3.min.js"></script>
	<script type="text/javascript" src="${basePath}/script/jquery.mousewheel-3.0.4.pack.js"></script>
	<script type="text/javascript" src="script/jquery.tipTip.minified.js"></script>
	<script type="text/javascript" src="${basePath}/script/simpla.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
		
			$("#main-nav-a-new").addClass("current");
			//add remove allUsers selectUsers hiddenUsers
			$("#add").click(function(){
				$("#allUsers option:selected").each(function(){
					$("#selectUsers").append($(this));
				});
				addToUsers();
			});
			$("#remove").click(function(){
				$("#selectUsers option:selected").each(function(){
					$("#allUsers").append($(this));
				});
				addToUsers();
			});
			$("#subbutton").click(function(){
				var projectname = $("#projectname").val();
				var hiddenusers = $("#hiddenUsers").val();
				if(projectname.trim().length == 0) {
					$("#notifyMessage div").html("请输入项目名称!").parent().slideDown().show().fadeTo(400,1);
				} else if(hiddenusers.trim().length == 0) {
					$("#notifyMessage div").html("请添加项目成员!").parent().slideDown().show().fadeTo(400,1);
				} else {
					$("#projectform").submit();
				} 
			});
		});
		function addToUsers() {
			$("#hiddenUsers").val("");
			$("#selectUsers option").each(function(){
				$("#hiddenUsers").val($("#hiddenUsers").val()+","+$(this).val());
			});
			var value = $("#hiddenUsers").val();
			$("#hiddenUsers").val(value.substring(1,value.length));
		}
	</script>
</head>
<body>
	<div id="body-wrapper">
		<!-- sidebar开始 -->
		<%@ include file="left.jsp" %>
		<!-- sidebar结束 -->
		<!-- main-content开始 -->
		<div id="main-content">
			<div class="content-box closed-box">
				<div class="content-box-header">
					<h3><a href="index.jspx">首页</a>&gt 新建项目</h3>
				</div>
			</div>
			<div class="content-box">
				<div class="content-box-header">
					<h3>新建项目</h3>
				</div>
				<div class="content-box-content">
					<form id="projectform" action="project!save.jspx" method="post">
						<div id="notifyMessage" class="notification attention png_bg" style="opacity: 0; display: none;">
							<a class="close" href="#">
								<img alt="close" title="Close this notification" src="${basePath }/images/cross_grey_small.png"/>
							</a>
							<div>
							</div>
						</div>
						<div>
							<label for="projectname">项目名称</label>
							<input type="hidden" name="users" id="hiddenUsers" />
							<input type="text" name="name" id="projectname" />
						</div>
						<div class="clear"></div>
						<div>
							<label for="projectuser">项目成员</label>
							<select id="allUsers" size="6" multiple="multiple" style="width: 43%">
								<c:forEach items="${userList}" var="user">
									<option value="${user.id}">${user.name}</option>
								</c:forEach>
							</select>
								<input type="button" class="button" id="add" value="添加" />
								<input type="button" class="button" id="remove" value="移除" />
							<select id="selectUsers" size="6" style="width: 43%">
								
							</select>
						</div>
						<div>
							<input id="subbutton" type="button" class="button right" value="创建" />
						</div>
					</form>
					<div class="clear"></div>
				</div>
			</div>
			<!-- 新建项目结束 -->
			<%@include file="foot.jsp" %>
		</div>
		<!-- main-content结束 -->
	</div>
</body>
</html>
